package com;

import javax.swing.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Scanner;

/**
 * @author 吴宇~
 * @motto 我亦无他，唯手熟尔。
 * @edition jdk1.8
 * @reflection 0-1 喧闹任其喧闹，自由我自为之，我自风情万种，与世无争。
 * @person Han Xiaojiu
 */
public class TankGame04 extends JFrame {
    MyPanel mp = null;
    Scanner in=new Scanner(System.in);
    public TankGame04() {
        System.out.println("请输入选择：(1:新的游戏  2:继续上局)");
        String key=in.next();
        mp = new MyPanel(key);
        this.add(mp);
        //将mp放入到Thread后启动
        Thread thread = new Thread(mp);
        thread.start();
        this.setSize(1350, 750);
        this.addKeyListener(mp);
        //在JF中增加监听响应关闭窗口的处理，
        this.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                System.out.println("监听到关闭窗口了");
                Recorder.keepRecord();
                System.exit(0);
            }
        });
        this.setDefaultCloseOperation(JInternalFrame.EXIT_ON_CLOSE);//一般有这句,关闭界面就算结束运行程序了
        this.setVisible(true);
    }
    public static void main(String[] args) {
        new  TankGame04();
    }
}
